//
//  YFCityPartnerViewController.m
//  QuanJieShopProject
//
//  Created by apple on 2018/5/26.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "YFCityPartnerViewController.h"
#import "YFCityPartnerCell.h"
#import "YFCityPartnerHeaderView.h"

@interface YFCityPartnerViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) UITableView *tableView;


@property (nonatomic, strong) UIView *headerContentView;
@end

@implementation YFCityPartnerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"城市合伙人";
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    // 本地数据源
    NSArray *titleArr = @[@"七天分红记录",@"我的店铺",@"所有店铺",@"我的推荐码",@"运营中心收益(仅鄂州显示)"];
    NSArray *imgArr = @[@"Mshouyi", @"kaidian", @"kaidian", @"Mtuijian", @"Mshouyi"];
    for (int i = 0; i < titleArr.count; i++) {
        YFCityPartnerModel *model = [[YFCityPartnerModel alloc] initWithTitle:titleArr[i] imgStr:imgArr[i]];
        [self.dataArr addObject:model];
    }
    [self.tableView reloadData];
}

#pragma mark - delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YFCityPartnerCell *cell = [YFCityPartnerCell cellWithTableView:tableView];
    cell.model = self.dataArr[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//    QJShopDetailVC *VC = [QJShopDetailVC new];
//    YFBrowseRecordModel *model = self.dataArr[indexPath.row];
//    VC.goodsID = [NSString stringWithoutNilFormart:model.goods_id];
//    KPushViewControllerAction(VC);
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 54;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 200;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    YFCityPartnerHeaderView *view = [[YFCityPartnerHeaderView alloc] init];
    return view;
}

#pragma mark - 懒加载
- (UITableView *)tableView{
    if (!_tableView) {
//        CGFloat top = IS_iOS11Later ? Height_NavBar : 0;
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH, UISCREEN_HEIGHT )];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.contentInset = UIEdgeInsetsMake(0, 0, 60, 0);
        _tableView.backgroundColor = YFColor_Background;
        [self.view addSubview:_tableView];
  
    }
    return _tableView;
}

- (NSMutableArray *)dataArr {
    if (!_dataArr) {
        _dataArr = [NSMutableArray array];
    }
    return _dataArr;
}

@end
